<?php

namespace App\Jobs;

use App\Models\User;
use Carbon\Carbon;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldBeUnique;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use App\Services\MakeProductOrder\MakeProductOrder;

class MakeSeckillOrderAddressJob implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    public int $uid;
    public string $cacheId;
    public object $address;
    /**
     * Create a new job instance.
     *
     * @return void
     */
     public function __construct($uid, $cacheId , $address)
    {
        $this->uid = $uid;
        $this->cacheId = $cacheId;
        $this->address = $address;
        $this->delay(Carbon::now()->addMinutes(1));
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
         $this->user = User::find($this->uid);
         $order = app(MakeProductOrder::class, [
            'user' => $this->user,
            'address' => $this->address,
            'items' => [],
            'cacheId' => $this->cacheId
        ])->addAddress();
    }
}
